﻿using FairyGUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class PackPage : BasePage
{
    private GList lsPackMenu;

    private PackEquipPage equipPackPage;
    private PackItemPage itemPackPage;
    private PackHeroPage heroPackPage;

    public PackPage(GComponent vie) : base(vie)
    {
        lsPackMenu = view.GetChild("n1").asList;
        lsPackMenu.onClickItem.Add(OnPackMenuClick);

        equipPackPage = new PackEquipPage(view.GetChild("n3").asCom);
        itemPackPage = new PackItemPage(view.GetChild("n2").asCom);
        heroPackPage = new PackHeroPage(view.GetChild("n4").asCom);
    }

    public override void Show()
    {
        lsPackMenu.selectedIndex = 0;
        lsPackMenu.onClickItem.Call();
    }

    public override void Close()
    {
    }

    public override void Dispose()
    {
        base.Dispose();
    }

    private void OnPackMenuClick(EventContext context)
    {
        if (lsPackMenu.selectedIndex == 0)
        {
            //道具
            itemPackPage.Show();
            equipPackPage.Close();
            heroPackPage.Close();
        }
        else if (lsPackMenu.selectedIndex == 1)
        {
            //装备
            equipPackPage.Show();
            itemPackPage.Close();
            heroPackPage.Close();
        }
        else if (lsPackMenu.selectedIndex == 2)
        {
            //伙伴
            heroPackPage.Show();
            itemPackPage.Close();
            equipPackPage.Close();
        }
    }
}
